@using BlazorApp.Pages.Common
@using BlazorApp.Pages.Common.Html
@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using k8s.Models
@inherits BlazorApp.Pages.Common.PageBase

@if (Rules is { Count: > 0 })
{
    <HTableColumn Title="@Title" ExplainField="ingress.spec.rules.http">
        @foreach (var rule in Rules)
        {
            <HTable Class="miniTable">

                <HTableColumn Title=@L["Host"] ExplainField="ingress.spec.rules.host">
                    <ColorfulTag>@(rule.Host ?? "*") </ColorfulTag>
                </HTableColumn>


                @if (rule.Http.Paths is { Count: > 0 })
                {
                    @foreach (var path in rule.Http.Paths)
                    {
                        <PropertyOptionView Title=@L["PathType"] Item="@path.PathType"
                                            Options='@(new[] { "Exact", "Prefix", "ImplementationSpecific" })'
                                            ExplainField="ingress.spec.rules.http.paths.pathType">
                        </PropertyOptionView>
                        <HTableColumn Title=@L["Path"] ExplainField="ingress.spec.rules.http.paths.path">
                            <ColorfulTag>@path.Path</ColorfulTag>
                            ==>
                            <IngressBackendNoTableView Namespace="@Namespace"
                                                       Backend="@path.Backend">
                            </IngressBackendNoTableView>
                        </HTableColumn>
                    }
                }

            </HTable>
        }
    </HTableColumn>
}

@code {

    [Parameter] public IList<V1IngressRule> Rules { get; set; }

    [Parameter] public string Title { get; set; }
    [Parameter] public string Namespace { get; set; }

}
